<template>
  <div class="risk-compliance c-shadow">
    <div class="judgment">
      <h4 class="detail-base-title">裁判文书<span>{{total || 0}}</span></h4>
      <j-no-data v-if="writData.length === 0" :mode="'b'" msg="b"></j-no-data>
      <div class="table-wrap" v-else>
        <table>
          <thead>
            <tr>
              <th v-for="title in writ" :key="title">{{title}}</th>
              <th>详情</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(item,idx) in writData" :key="item.writ">
              <td>{{item.publishtime | dateFormat}}</td>
              <td>{{item.type || '--'}}</td>
              <td>{{item.casecode || '--'}}</td>
              <td class="courtName" :title="item.courtname">{{item.courtname || '--'}}</td>
              <td><button class="cancle-btn" @click="getInfo(writData[idx],1)"><span>查看</span> </button></td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="block paging-wrap fr">
        <el-pagination v-if="total>5"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="pageNum"
          :page-size="pageSize"
          layout="prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </div>
    </div>
    <div class="executor clearFix">
        <h4 class="detail-base-title">法院被执行人<span>{{total3 || 0}}</span></h4>
        <j-no-data v-if="courtData.length === 0" :mode="'b'" msg="b"></j-no-data>
        <div class="table-wrap" v-else>
          <table>
            <thead>
              <tr>
                <th v-for="title in executor" :key="title">{{title}}</th>
                <th>详情</th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(item,idx) in courtData" :key="item.writ">
                <td>{{item.executeDate | dateFormat}}</td>
                <td>{{item.executerName || '--'}}</td>
                <td>{{item.caseNo || '--'}}</td>
                <td>{{item.court || '--'}}</td>
                <td><button class="cancle-btn" @click="getInfo(courtData[idx],2)"><span>查看</span> </button></td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="block paging-wrap fr">
          <el-pagination v-if="total3>5"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange3"
            :current-page.sync="pageNum3"
            :page-size="pageSize3"
            layout="prev, pager, next, jumper"
            :total="total3">
          </el-pagination>
        </div>
    </div>
    <div class="sx-record clearFix">
        <h4 class="detail-base-title">被执行人失信记录<span>{{total1 || 0}}</span></h4>
        <j-no-data v-if="sxData.length === 0" :mode="'b'" msg="b"></j-no-data>
        <div class="table-wrap" v-else>
          <table>
            <thead>
              <tr>
                <th v-for="title in executor" :key="title">{{title}}</th>
                <th>详情</th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(item,idx) in sxData" :key="item.idx">
                <td>{{item.publishDate | dateFormat}}</td>
                <td>{{item.executerName || '--'}}</td>
                <td>{{item.caseNo || '--'}}</td>
                <td>{{item.count || '--'}}</td>
                <td><button class="cancle-btn" @click="getInfo(sxData[idx],3)"><span>查看</span> </button></td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="paging-wrap feature_wrap fr" v-if="total>5">
          <el-pagination v-if="total1>5"
          @size-change="handleSizeChange"
            @current-change="handleCurrentChange1"
            :current-page.sync="pageNum1"
            :page-size.sync="pageSize1"
            layout="prev, pager, next, jumper"
            :total.sync="total1">
          </el-pagination>
        </div>
    </div>
    <div class="sw-punish clearFix">
        <h4 class="detail-base-title">税务处罚<span>{{total2 || 0}}</span></h4>
        <j-no-data v-if="swData.length === 0" :mode="'b'" msg="b"></j-no-data>
        <div class="table-wrap" v-else>
          <table>
            <thead>
              <tr>
                <th v-for="title in tax" :key="title">{{title}}</th>
                <th>详情</th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(item,idx) in swData" :key="item.idx">
                <td>{{item.punishStartTime | dateFormat}}</td>
                <td>{{item.punishEndTime | dateFormat}}</td>
                <td>{{item.taxCode || '--'}}</td>
                <td>{{item.name || '--'}}</td>
                <td>{{item.caseCode || '--'}}</td>
                <td><button class="cancle-btn" @click="getInfo(swData[idx],4)"><span>查看</span> </button></td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="paging-wrap fr">
          <el-pagination v-if="total2>5"
          @size-change="handleSizeChange"
            @current-change="handleCurrentChange2"
            :current-page.sync="pageNum2"
            :page-size.sync="pageSize2"
            layout="prev, pager, next, jumper"
            :total.sync="total2">
          </el-pagination>
        </div>
    </div>
    <div class="hb-punish clearFix">
        <h4 class="detail-base-title">环保处罚<span>{{total4 || 0}}</span></h4>
        <j-no-data v-if="hbData.length === 0" :mode="'b'" msg="b"></j-no-data>
        <div class="table-wrap" v-else>
          <table>
            <thead>
              <tr>
                <th v-for="title in environmental" :key="title">{{title}}</th>
                <th>详情</th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(item,idx) in hbData" :key="item.idx">
                <td>{{item.punishDate | dateFormat}}</td>
                <td>{{item.punishType || '--'}}</td>
                <td>{{item.caseCode || '--'}}</td>
                <td>{{item.punishOrg || '--'}}</td>
                <td><button class="cancle-btn" @click="getInfo(hbData[idx],5)"><span>查看</span> </button></td>
              </tr>
            </tbody>
          </table>
        </div>
        <div class="paging-wrap fr">
          <el-pagination v-if="total4>5"
          @size-change="handleSizeChange"
            @current-change="handleCurrentChange4"
            :current-page.sync="pageNum4"
            :page-size.sync="pageSize4"
            layout="prev, pager, next, jumper"
            :total.sync="total4">
          </el-pagination>
        </div>
    </div>
    <div class="yjh-punish clearFix">
      <h4 class="detail-base-title">银监会处罚<span>{{total5 || 0}}</span></h4>
      <j-no-data v-if="comData.length === 0" :mode="'b'" msg="b"></j-no-data>
      <div class="table-wrap" v-else>
        <table>
          <thead>
            <tr>
              <th v-for="title in commission" :key="title">{{title}}</th>
              <th>详情</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(item,idx) in comData" :key="item.idx">
              <td>{{item.punishmentDate | dateFormat}}</td>
              <td>{{item.bookNumber || '--'}}</td>
              <td>{{item.reason || '--'}}</td>
              <td>{{item.punishOrg || '--'}}</td>
              <td><button class="cancle-btn" @click="getInfo(comData[idx],6)"><span>查看</span> </button></td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="paging-wrap fr">
        <el-pagination v-if="total5>5"
        @size-change="handleSizeChange"
          @current-change="handleCurrentChange5"
          :current-page.sync="pageNum5"
          :page-size.sync="pageSize5"
          layout="prev, pager, next, jumper"
          :total.sync="total5">
        </el-pagination>
      </div>
    </div>
    <div class="zjh-punish clearFix">
      <h4 class="detail-base-title">证监会处罚<span>{{total6 || 0}}</span></h4>
      <j-no-data v-if="zhengjhData.length === 0" :mode="'b'" msg="b"></j-no-data>
      <div class="table-wrap" v-else>
        <table>
          <thead>
            <tr>
              <th v-for="title in zhengjh" :key="title">{{title}}</th>
              <th>详情</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(item,idx) in zhengjhData" :key="item.idx">
              <td>{{item.pubTime | dateFormat}}</td>
              <td>{{item.bookid || '--'}}</td>
              <td>{{item.dept || '--'}}</td>
              <td><button class="cancle-btn" @click="getInfo(zhengjhData[idx],7)"><span>查看</span> </button></td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="paging-wrap fr">
        <el-pagination v-if="total6>5"
        @size-change="handleSizeChange"
          @current-change="handleCurrentChange6"
          :current-page.sync="pageNum6"
          :page-size.sync="pageSize6"
          layout="prev, pager, next, jumper"
          :total.sync="total6">
        </el-pagination>
      </div>
    </div>
    <div class="bjh-punish clearFix">
      <h4 class="detail-base-title">保监会处罚<span>{{total7 || 0}}</span></h4>
      <j-no-data v-if="baojhData.length === 0" :mode="'b'" msg="b"></j-no-data>
      <div class="table-wrap" v-else>
        <table>
          <thead>
            <tr>
              <th v-for="title in baojh" :key="title">{{title}}</th>
              <th>详情</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="(item,idx) in baojhData" :key="item.baojhData">
              <td>{{item.pubTime | dateFormat}}</td>
              <td>{{item.content || '--'}}</td>
              <td>{{item.bookName || '--'}}</td>
              <td><button class="cancle-btn" @click="getInfo(baojhData[idx],8)"><span>查看</span> </button></td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="paging-wrap fr">
        <el-pagination v-if="total7>5"
        @size-change="handleSizeChange"
          @current-change="handleCurrentChange7"
          :current-page.sync="pageNum7"
          :page-size.sync="pageSize7"
          layout="prev, pager, next, jumper"
          :total.sync="total7">
        </el-pagination>
      </div>
    </div>
    <el-dialog title="详情" :visible.sync="show" width="80%">
      <div class="table-wrap">
        <table>
          <tbody>
            <tr v-for="(item,idx) in contentKey" :key="idx" v-if="getValue(item)">
              <td width="18%" style="text-align:left">{{item}}</td>
              <td v-if="item.indexOf('链接') !== -1" style="text-align:left">
                <a target="_blank" :href="getValue(item)">{{getValue(item)}}</a>
              </td>
              <td v-else style="text-align:left">{{getValue(item)}}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </el-dialog>
    <!-- <jDialog :initShow="show" initTitle="详情" @closing="resetShow">
      {{getValue("cccc")}}
      <div class="table-wrap">
      <table>
        <tbody>
          <tr v-for="(item,idx) in contentKey" :key="idx" v-if="getValue(item)">
            <td width="25%" style="text-align:left">{{item}}</td>
            <td style="text-align:left">{{getValue(item)}}</td>
          </tr>
        </tbody>
      </table>
    </div>
    </jDialog> -->
  </div>
</template>
<script>
import { jNoData, jDialog } from '../../components'
import { sysSetting as api } from '../../api'
import { dir } from '../../assets/js/dir'
export default {
  data() {
    return {
      dialogContent: '',
      show: false,
      writ: ['裁判日期', '案件类型', '案号', '法院名称'],
      writData: [],
      executor: ['立案时间', '被执行人姓名/名称', '案号', '执行法院'],
      courtData: [],
      sxData: [],
      tax: [
        '处罚生效日期',
        '处罚截止日期',
        '税务登记号',
        '纳税人姓名',
        '行政处罚决定书文号'
      ],
      swData: [],
      environmental: [
        '处罚日期',
        '处罚类型',
        '行政处罚决定书文号',
        '作出处罚决定的机关'
      ],
      hbData: [],
      commission: [
        '处罚决定的日期',
        '行政处罚决定书文号',
        '主要违法违规事实',
        '决定机关'
      ],
      comData: [],
      zhengjh: ['发文日期', '行政处罚决定书文号', '发文机构'],
      zhengjhData: [],
      baojh: ['发布时间', '事件名称', '行政处罚决定书文号'],
      baojhData: [],
      params: {},
      pageNum: 1,
      pageSize: 5,
      total: 0,
      pageNum1: 1,
      pageSize1: 5,
      total1: 0,
      pageNum2: 1,
      pageSize2: 5,
      total2: 0,
      pageNum3: 1,
      pageSize3: 5,
      total3: 0,
      pageNum4: 1,
      pageSize4: 5,
      total4: 0,
      pageNum5: 1,
      pageSize5: 5,
      total5: 0,
      pageNum6: 1,
      pageSize6: 5,
      total6: 0,
      pageNum7: 1,
      pageSize7: 5,
      total7: 0,
      number: '',
      entId: '',
      contentDir: [],
      contentKey: []
    }
  },
  mounted() {
    this.params.entName = this.$route.query.entname
    this.getRefereeList()
    this.getExecutorInfoList()
    this.getBreakFaithList()
    this.getSwList()
    this.getHbList()
    this.getYjhList()
    this.getZjhList()
    this.getBjhList()
  },
  computed: {
    getValue() {
      return function(val) {
        let dialogContent = this.dialogContent
        if (typeof dialogContent === 'object') {
          let rtVal = dialogContent.get(val)
          return !isNaN(rtVal) && rtVal.toString().length === 13
            ? this.$options.filters['dateFormat'](rtVal)
            : rtVal
        } else {
          return false
        }
      }
    }
  },
  methods: {
    changeInt(content) {
      let conMap = new Map()
      let contentDir = new Map(this.contentDir)
      for (let key of Object.keys(content)) {
        let name = contentDir.get(key)
        conMap.set(name, content[key])
      }
      this.dialogContent = conMap
    },
    // 关闭dialog
    resetShow(blur) {
      this.show = blur.cancleClose
    },
    // 查看详情
    getInfo(content, idx) {
      let contentDir = 'contentDir_' + idx
      this.contentDir = dir[contentDir]
      let contentKey = [...new Map(this.contentDir).values()]
      this.contentKey = contentKey
      this.changeInt(content)
      this.show = true
    },
    // 获取合规风险总数
    getNumber() {
      api.getRiskCount({ entId: this.$route.query.entid }).then(rtn => {
        this.number = rtn.data
      })
    },
    // 获取裁判文书列表
    getRefereeList() {
      let _this = this
      let params = {
        pageNum: _this.pageNum,
        pageSize: _this.pageSize
      }
      api
        .getfindRefereeList({ ..._this.params, ...params })
        .then(rtn => {
          _this.writData = rtn.data.list
          // console.log(rtn.data)
          _this.total = rtn.data.total
        })
        .catch(err => {
          _this.pageState = err
        })
    },
    handleSizeChange() {
      // 当pagesize改变的时候出发该函数
    },
    handleCurrentChange(index) {
      this.pageNum = index
      this.getRefereeList()
    },
    // 获取法院被执行人
    getExecutorInfoList() {
      let _this = this
      let params = {
        pageNum: _this.pageNum3,
        pageSize: _this.pageSize3
      }
      api
        .getExecutorInfoList({ ..._this.params, ...params })
        .then(rtn => {
          _this.courtData = rtn.data.list
          _this.total3 = rtn.data.total
        })
        .catch(err => {
          _this.pageState = err
        })
    },
    handleCurrentChange3(index) {
      this.pageNum3 = index
      this.getExecutorInfoList()
    },
    // 获取被执行人失信记录
    getBreakFaithList() {
      let _this = this
      let params = {
        pageNum: _this.pageNum1,
        pageSize: _this.pageSize1
      }
      api
        .getBreakFaithList({ ..._this.params, ...params })
        .then(rtn => {
          _this.sxData = rtn.data.list
          _this.total1 = rtn.data.total
        })
        .catch(err => {
          _this.pageState = err
        })
    },
    handleCurrentChange1(index) {
      this.pageNum1 = index
      this.getBreakFaithList()
    },
    // 获取税务处罚
    getSwList() {
      let _this = this
      let params = {
        pageNum: _this.pageNum4,
        pageSize: _this.pageSize4
      }
      api
        .getSwList({ ..._this.params, ...params })
        .then(rtn => {
          _this.swData = rtn.data.list
          _this.total2 = rtn.data.total
        })
        .catch(err => {
          _this.pageState = err
        })
    },
    handleCurrentChange2(index) {
      this.pageNum2 = index
      this.getBreakFaithList()
    },
    // 获取环保处罚
    getHbList() {
      let _this = this
      let params = {
        pageNum: _this.pageNum4,
        pageSize: _this.pageSize4
      }
      api
        .getEnvironProtectList({ ..._this.params, ...params })
        .then(rtn => {
          _this.hbData = rtn.data.list
          _this.total4 = rtn.data.total
        })
        .catch(err => {
          _this.pageState = err
        })
    },
    handleCurrentChange4(index) {
      this.pageNum4 = index
      this.getHbList()
    },
    // 获取银监会处罚
    getYjhList() {
      let _this = this
      let params = {
        pageNum: _this.pageNum5,
        pageSize: _this.pageSize5
      }
      api
        .getCbrcPunishList({ ..._this.params, ...params })
        .then(rtn => {
          _this.comData = rtn.data.list
          _this.total5 = rtn.data.total
        })
        .catch(err => {
          _this.pageState = err
        })
    },
    handleCurrentChange5(index) {
      this.pageNum5 = index
      this.getYjhList()
    },
    // 获取证监会处罚
    getZjhList() {
      let _this = this
      let params = {
        pageNum: _this.pageNum6,
        pageSize: _this.pageSize6
      }
      api
        .getCsrcPunishList({ ..._this.params, ...params })
        .then(rtn => {
          _this.zhengjhData = rtn.data.list
          _this.total6 = rtn.data.total
        })
        .catch(err => {
          _this.pageState = err
        })
    },
    handleCurrentChange6(index) {
      this.pageNum6 = index
      this.getZjhList()
    },
    getBjhList() {
      let _this = this
      let params = {
        pageNum: _this.pageNum7,
        pageSize: _this.pageSize7
      }
      api
        .getCircPunishList({ ..._this.params, ...params })
        .then(rtn => {
          _this.baojhData = rtn.data.list
          _this.total7 = rtn.data.total
        })
        .catch(err => {
          _this.pageState = err
        })
    },
    handleCurrentChange7(index) {
      this.pageNum7 = index
      this.getBjhList()
    }
  },
  components: {
    jNoData,
    jDialog
  }
}
</script>
<style lang="scss" scoped>
.risk-compliance {
  padding: 28px 40px;
  font-size: 14px;
  .detail-base-title {
    line-height: 30px;
    font-size: 16px;
    font-weight: bold;
    padding: 30px 0 0 12px;
    position: relative;
    background-image: linear-gradient(0deg, #1891ef, #1891ef);
    background-size: 3px 16px;
    background-position: 0 37px;
    background-repeat: no-repeat;
    border-bottom: 1px solid #eee;
  }
  h4.detail-base-title span {
    border: 1px solid #9dc5fd;
    border-radius: 10px;
    color: #1688f3;
    background: #f2f7ff;
    font-size: 12px;
    padding: 0 10px;
    margin-left: 15px;
    vertical-align: top;
  }
  .table-wrap {
    padding: 30px 20px;
    table {
      border-collapse: collapse;
      width: 100%;
      text-align: center;
      td,
      th {
        border: 1px solid #e2e2e2;
        line-height: 40px;
      }
      th {
        line-height: 38px;
        color: #999;
        background: #f2f1f1;
      }
    }
  }
  .table-wrap {
    padding: 0;
  }
  table {
    text-align: left;
    td {
      padding: 0 10px;
    }
  }
  /deep/ .el-dialog__header {
    padding: 10px;
    background: #3f8ffa;
    .el-dialog__title {
      color: #fff;
    }
    .el-dialog__headerbtn {
      top: 12px;
      i {
        color: #fff;
      }
    }
  }
  .courtName {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}
</style>



// WEBPACK FOOTER //
// src/view/entDetail/riskCompliance.vue